﻿Imports System
Imports System.IO
Imports System.Data
Imports System.Reflection
Imports System.Data.SqlClient
Imports IDServer
Imports Infragistics
Imports Microsoft.VisualBasic

''' <summary>
'''     建立日期：2010-4-19
'''       建立者：JASON
'''   最后修改人：JASON
''' 最后修改日期：2010-4-19
''' </summary>
''' <remarks></remarks>
''' 

Public Class Frm_MainForm


    Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Integer, ByVal wMsg As Integer, ByVal wParam As Integer, ByVal lParam As Integer) As Integer
    Private Declare Sub ReleaseCapture Lib "User32" ()
    Const WM_NCLBUTTonDOWN = &HA1
    Const HTCAPTION = 2

    Public ActionHelp As IDServer.IDServer.ActionBtn = IDServer.IDServer.ActionBtn.ActionHelp
    Private mDecrypt As New IDServer.IDSecurity
    Private mIndex As Integer = 64
    Public mBool As Boolean = False
    Private IsTran As Boolean = False
    Private mDataset As DataSet
    Private UserDataSet As DataSet
    Private SelectObject As Object
    Private SelectNode As TreeNode
    Private SelectDS As DataSet
    Private IntialHashtable As New Hashtable
    Private ModeControls As DataTable
    Private ask As Boolean = False

#Region " Menu Items "

#Region "加載所有菜單的方法（update by weiqi）"
    '以前每個菜單都用了一個獨立的方法，現在將它們整合到這幾個方法里
    '并修改成使用ModeName來查詢，而不再使用ParentId來查詢
    Private Function GetFileMenu(ByVal modeName As String) As ToolStripMenuItem
        modeName = modeName.ToLower()
        Dim toolstrip As ToolStripMenuItem
        Select Case modeName
            Case "BSC".ToLower '基礎資料
                toolstrip = Me.BasicToolStripMenuItem
            Case "PUR".ToLower '采購管理
                toolstrip = Me.PurchaseToolStripMenuItem
            Case "Sal".ToLower '銷售管理
                toolstrip = Me.SalesToolStripMenuItem
            Case "Store".ToLower '庫存管理
                toolstrip = Me.StoreToolStripMenuItem
            Case "AR".ToLower '應收系統
                toolstrip = Me.ARToolStripMenuItem
            Case "AP".ToLower '應付系統
                toolstrip = Me.APToolStripMenuItem
            Case "GL".ToLower '財務系統
                toolstrip = Me.GLToolStripMenuItem
            Case "Sys".ToLower '系統定義
                toolstrip = Me.SystemToolStripMenuItem
            Case "delivery".ToLower '跟單管理
                toolstrip = Me.DelToolStripMenuItem
            Case "lo".ToLower '物流管理
                toolstrip = Nothing
            Case "cars".ToLower '車輛管理
                toolstrip = Nothing
            Case "CS".ToLower '客服管理
                toolstrip = Nothing
            Case "Manufacture".ToLower '生產管理
                toolstrip = Me.ProductToolStripMenuItem
            Case Else
                toolstrip = Nothing
        End Select
        Return toolstrip
    End Function
    ''' <summary>
    ''' 加載所有設定好的菜單
    ''' </summary>
    ''' <remarks></remarks>
    Private Sub LoadAllFileMenu()
        Dim modeNos As String = "BSC,PUR,Sal,Store,AR,AP,GL,Sys,delivery,lo,cars,CS,Manufacture"
        For Each modeNo As String In modeNos.Split((",").ToCharArray())
            LoadFileMenu(modeNo)
        Next
    End Sub
    ''' <summary>
    '''獲取模塊中控件的ParentID號
    ''' </summary>
    ''' <param name="ModeNo">模塊的名稱（egg. Store 表示庫存管理模塊）</param>
    ''' <returns></returns>
    ''' <remarks></remarks>
    Private Function GetModeID(ByVal ModeNo As String) As Int64
        Dim Id As Int64 = -1
        Dim Rows() As DataRow = mDataset.Tables(0).Select("ModeNo='" + ModeNo + "'")
        If Rows.Length > 0 Then
            Id = Convert.ToInt64(Rows(0)("ID").ToString)
        End If
        Return Id
    End Function
    ''' <summary>
    ''' 給主菜單填充子菜單，并設置好子菜單的一些參數
    ''' </summary>
    ''' <param name="ModeNo">模塊名稱</param>
    ''' <remarks></remarks>
    Private Sub LoadFileMenu(ByVal ModeNo As String)
        Try
            Dim id As Int64 = GetModeID(ModeNo)
            Dim Rows() As DataRow = mDataset.Tables(0).Select("ParentID=" + id.ToString)
            Dim moderows() As DataRow = mDataset.Tables(0).Select("ModeNo='" + ModeNo + "'")

            Dim mValue As System.Windows.Forms.ToolStripMenuItem
            '定義主菜單
            Dim menu As System.Windows.Forms.ToolStripMenuItem
            '獲取主菜單
            menu = GetFileMenu(ModeNo)
            If menu Is Nothing Then
                Exit Sub
            End If
            If moderows.Length > 0 Then
                '設置主菜單上顯示的字體
                menu.Text = moderows(0).Item("ModeName").ToString()
            End If
            Dim img As System.Drawing.Image
            Dim MenuPicture As String = ""
            Dim MapPath As String = ""
            If Rows.Length > 0 Then
                For Each mRow As DataRow In Rows
                    With menu.DropDownItems
                        mValue = New System.Windows.Forms.ToolStripMenuItem
                        MenuPicture = mDecrypt.DataDecrypt(mRow("ControlPicture").ToString.Replace("^", "'") & "")
                        MapPath = Application.StartupPath + "\pic\" + MenuPicture
                        If mIndex = 90 Then
                            mIndex = 64
                            IsTran = True
                        End If
                        mIndex += 1
                        mValue.Name = mRow("ControlName")
                        mValue.Tag = mRow("ID")
                        mValue.Text = mRow("ModeName")
                        If File.Exists(MapPath) Then
                            img = Image.FromFile(MapPath)
                            mValue.Image = img
                        End If
                        If IsTran = True Then
                            mValue.ShortcutKeys = Keys.Control + Keys.Alt + Asc(Chr(mIndex))
                        Else
                            mValue.ShortcutKeys = Keys.Alt + Asc(Chr(mIndex))
                        End If
                        .Add(mValue)
                        AddHandler mValue.Click, AddressOf SystemMenuClick
                    End With
                Next
            End If
        Catch ex As Exception
            MsgBox("LoadFileMenu:" + ex.ToString, MsgBoxStyle.Exclamation + MsgBoxStyle.OkOnly, Msg.CompanyName)
        End Try
    End Sub

#End Region

#Region "下面的方法不再需要,因為前面的幾個方面已經實現了同樣的功能（record by weiqi）"

    ''' <summary>
    ''' The Basic Menu
    ''' </summary>
    ''' <remarks></remarks>
    Private Sub LoadBasicFileMenu()
        Try
            Dim Rows() As DataRow = mDataset.Tables(0).Select("ParentID=1")
            Dim mValue As System.Windows.Forms.ToolStripMenuItem
            Dim img As System.Drawing.Image
            Dim MenuPicture As String = ""
            Dim MapPath As String = ""
            If Rows.Length > 0 Then
                For Each mRow As DataRow In Rows
                    With Me.BasicToolStripMenuItem.DropDownItems
                        mValue = New System.Windows.Forms.ToolStripMenuItem
                        MenuPicture = mDecrypt.DataDecrypt(mRow("ControlPicture").ToString.Replace("^", "'") & "")
                        MapPath = Application.StartupPath + "\pic\" + MenuPicture
                        If mIndex = 90 Then
                            mIndex = 64
                            IsTran = True
                        End If
                        mIndex += 1
                        mValue.Name = mRow("ControlName")
                        mValue.Tag = mRow("ID")
                        mValue.Text = mRow("ModeName")
                        If File.Exists(MapPath) Then
                            img = Image.FromFile(MapPath)
                            mValue.Image = img
                        End If
                        If IsTran = True Then
                            mValue.ShortcutKeys = Keys.Control + Keys.Alt + Asc(Chr(mIndex))
                        Else
                            mValue.ShortcutKeys = Keys.Alt + Asc(Chr(mIndex))
                        End If
                        .Add(mValue)
                        AddHandler mValue.Click, AddressOf SystemMenuClick
                        'If UserDataSet.Tables(0).Rows.Count > 0 Then
                        '    Dim ModeName As String = UserDataSet.Tables(0).Rows(0).Item("ModeName") & ""
                        '    If ModeName.IndexOf(mValue.Name) > -1 Then
                        '        .Add(mValue)
                        '        AddHandler mValue.Click, AddressOf SystemMenuClick
                        '    End If
                        'End If
                    End With
                Next
            End If

        Catch ex As Exception
            Throw ex
        End Try
    End Sub
    ''' <summary>
    ''' The Sale Menu
    ''' </summary>
    ''' <remarks></remarks>
    Private Sub LoadSaleFileMenu()
        Try
            Dim Rows() As DataRow = mDataset.Tables(0).Select("ParentID=5")
            Dim mValue As System.Windows.Forms.ToolStripMenuItem
            Dim img As System.Drawing.Image
            Dim MenuPicture As String = ""
            Dim MapPath As String = ""
            If Rows.Length > 0 Then
                For Each mRow As DataRow In Rows
                    With Me.SalesToolStripMenuItem.DropDownItems
                        mValue = New System.Windows.Forms.ToolStripMenuItem
                        MenuPicture = mDecrypt.DataDecrypt(mRow("ControlPicture").ToString.Replace("^", "'") & "")
                        MapPath = Application.StartupPath + "\pic\" + MenuPicture
                        If mIndex = 90 Then
                            mIndex = 64
                            IsTran = True
                        End If
                        mIndex += 1
                        mValue.Name = mRow("ControlName")
                        mValue.Tag = mRow("ID")
                        mValue.Text = mRow("ModeName")
                        If File.Exists(MapPath) Then
                            img = Image.FromFile(MapPath)
                            mValue.Image = img
                        End If
                        If IsTran = True Then
                            mValue.ShortcutKeys = Keys.Control + Keys.Alt + Asc(Chr(mIndex))
                        Else
                            mValue.ShortcutKeys = Keys.Alt + Asc(Chr(mIndex))
                        End If
                        .Add(mValue)
                        AddHandler mValue.Click, AddressOf SystemMenuClick

                        'If UserDataSet.Tables(0).Rows.Count > 0 Then
                        '    Dim ModeName As String = UserDataSet.Tables(0).Rows(0).Item("ModeName") & ""
                        '    If ModeName.IndexOf(mValue.Name) > -1 Then

                        '    End If
                        'End If
                    End With
                Next
            End If
        Catch ex As Exception
            Throw ex
        End Try
    End Sub
    ''' <summary>
    ''' The Purchar Menu
    ''' </summary>
    ''' <remarks></remarks>
    Private Sub LoadOrdeFileMenu()
        Try
            Dim Rows() As DataRow = mDataset.Tables(0).Select("ParentID=4")
            Dim mValue As System.Windows.Forms.ToolStripMenuItem
            Dim img As System.Drawing.Image
            Dim MenuPicture As String = ""
            Dim MapPath As String = ""

            If Rows.Length > 0 Then
                For Each mRow As DataRow In Rows
                    With Me.PurchaseToolStripMenuItem.DropDownItems
                        mValue = New System.Windows.Forms.ToolStripMenuItem
                        MenuPicture = mDecrypt.DataDecrypt(mRow("ControlPicture").ToString.Replace("^", "'") & "")
                        MapPath = Application.StartupPath + "\pic\" + MenuPicture

                        If mIndex = 90 Then
                            mIndex = 64
                            IsTran = True
                        End If
                        mIndex += 1
                        mValue.Name = mRow("ControlName")
                        mValue.Tag = mRow("ID")
                        mValue.Text = mRow("ModeName")
                        If File.Exists(MapPath) Then
                            img = Image.FromFile(MapPath)
                            mValue.Image = img
                        End If
                        If IsTran = True Then
                            mValue.ShortcutKeys = Keys.Control + Keys.Alt + Asc(Chr(mIndex))
                        Else
                            mValue.ShortcutKeys = Keys.Alt + Asc(Chr(mIndex))
                        End If
                        .Add(mValue)
                        AddHandler mValue.Click, AddressOf SystemMenuClick

                        'If UserDataSet.Tables(0).Rows.Count > 0 Then
                        '    Dim ModeName As String = UserDataSet.Tables(0).Rows(0).Item("ModeName") & ""
                        '    If ModeName.IndexOf(mValue.Name) > -1 Then

                        '    End If
                        'End If
                    End With
                Next
            End If

        Catch ex As Exception
            Throw ex
        End Try
    End Sub
    ''' <summary>
    '''The Store Menu
    ''' </summary>
    ''' <remarks></remarks>
    Private Sub LoadStoreFileMenu()
        Try
            Dim Rows() As DataRow = mDataset.Tables(0).Select("ParentID=6")
            Dim mValue As System.Windows.Forms.ToolStripMenuItem
            Dim mBool As Boolean = False
            Dim img As System.Drawing.Image
            Dim MenuPicture As String = ""
            Dim MapPath As String = ""

            If Rows.Length > 0 Then
                For Each mRow As DataRow In Rows
                    With Me.StoreToolStripMenuItem.DropDownItems
                        mValue = New System.Windows.Forms.ToolStripMenuItem
                        MenuPicture = mDecrypt.DataDecrypt(mRow("ControlPicture").ToString.Replace("^", "'") & "")
                        MapPath = Application.StartupPath + "\pic\" + MenuPicture
                        If mIndex = 90 Then
                            mIndex = 64
                            IsTran = True
                        End If
                        mIndex += 1
                        mValue.Name = mRow("ControlName")
                        mValue.Tag = mRow("ID")
                        mValue.Text = mRow("ModeName")
                        If File.Exists(MapPath) Then
                            img = Image.FromFile(MapPath)
                            mValue.Image = img
                        End If
                        If IsTran = True Then
                            mValue.ShortcutKeys = Keys.Control + Keys.Alt + Asc(Chr(mIndex))
                        Else
                            mValue.ShortcutKeys = Keys.Alt + Asc(Chr(mIndex))
                        End If
                        .Add(mValue)
                        AddHandler mValue.Click, AddressOf SystemMenuClick

                        'If UserDataSet.Tables(0).Rows.Count > 0 Then
                        '    Dim ModeName As String = UserDataSet.Tables(0).Rows(0).Item("ModeName") & ""
                        '    If ModeName.IndexOf(mValue.Name) > -1 Then
                        '        .Add(mValue)
                        '        AddHandler mValue.Click, AddressOf SystemMenuClick
                        '    End If
                        'End If
                    End With
                Next
            End If

        Catch ex As Exception
            Throw ex
        End Try
    End Sub
    ''' <summary>
    ''' The AR File Menu
    ''' </summary>
    ''' <remarks></remarks>
    Private Sub LoadARFileMenu()

        Try
            Dim Rows() As DataRow = mDataset.Tables(0).Select("ParentID=19")
            Dim mValue As System.Windows.Forms.ToolStripMenuItem
            Dim img As System.Drawing.Image
            Dim MenuPicture As String = ""
            Dim MapPath As String = ""
            If Rows.Length > 0 Then
                For Each mRow As DataRow In Rows
                    With Me.ARToolStripMenuItem.DropDownItems
                        mValue = New System.Windows.Forms.ToolStripMenuItem
                        MenuPicture = mDecrypt.DataDecrypt(mRow("ControlPicture").ToString.Replace("^", "'") & "")
                        MapPath = Application.StartupPath + "\pic\" + MenuPicture
                        If mIndex = 90 Then
                            mIndex = 64
                            IsTran = True
                        End If
                        mIndex += 1
                        mValue.Name = mRow("ControlName")
                        mValue.Tag = mRow("ID")
                        mValue.Text = mRow("ModeName")
                        If File.Exists(MapPath) Then
                            img = Image.FromFile(MapPath)
                            mValue.Image = img
                        End If
                        If IsTran = True Then
                            mValue.ShortcutKeys = Keys.Control + Keys.Alt + Asc(Chr(mIndex))
                        Else
                            mValue.ShortcutKeys = Keys.Alt + Asc(Chr(mIndex))
                        End If
                        .Add(mValue)
                        AddHandler mValue.Click, AddressOf SystemMenuClick

                        'If UserDataSet.Tables(0).Rows.Count > 0 Then
                        '    Dim ModeName As String = UserDataSet.Tables(0).Rows(0).Item("ModeName") & ""
                        '    If ModeName.IndexOf(mValue.Name) > -1 Then
                        '        .Add(mValue)
                        '        AddHandler mValue.Click, AddressOf SystemMenuClick
                        '    End If
                        'End If
                    End With
                Next
            End If
        Catch ex As Exception
            MsgBox("LoadARFileMenu:" + ex.ToString, MsgBoxStyle.Exclamation + MsgBoxStyle.OkOnly, Msg.CompanyName)
        End Try

    End Sub
    ''' <summary>
    ''' The AP File Menu
    ''' </summary>
    ''' <remarks></remarks>
    Private Sub LoadAPFileMenu()

        Try
            Dim Rows() As DataRow = mDataset.Tables(0).Select("ParentID=51")
            Dim mValue As System.Windows.Forms.ToolStripMenuItem
            Dim img As System.Drawing.Image
            Dim MenuPicture As String = ""
            Dim MapPath As String = ""
            If Rows.Length > 0 Then
                For Each mRow As DataRow In Rows
                    With Me.APToolStripMenuItem.DropDownItems
                        mValue = New System.Windows.Forms.ToolStripMenuItem
                        MenuPicture = mDecrypt.DataDecrypt(mRow("ControlPicture").ToString.Replace("^", "'") & "")
                        MapPath = Application.StartupPath + "\pic\" + MenuPicture
                        If mIndex = 90 Then
                            mIndex = 64
                            IsTran = True
                        End If
                        mIndex += 1
                        mValue.Name = mRow("ControlName")
                        mValue.Tag = mRow("ID")
                        mValue.Text = mRow("ModeName")
                        If File.Exists(MapPath) Then
                            img = Image.FromFile(MapPath)
                            mValue.Image = img
                        End If
                        If IsTran = True Then
                            mValue.ShortcutKeys = Keys.Control + Keys.Alt + Asc(Chr(mIndex))
                        Else
                            mValue.ShortcutKeys = Keys.Alt + Asc(Chr(mIndex))
                        End If
                        .Add(mValue)
                        AddHandler mValue.Click, AddressOf SystemMenuClick

                        'If UserDataSet.Tables(0).Rows.Count > 0 Then
                        '    Dim ModeName As String = UserDataSet.Tables(0).Rows(0).Item("ModeName") & ""
                        '    If ModeName.IndexOf(mValue.Name) > -1 Then
                        '        .Add(mValue)
                        '        AddHandler mValue.Click, AddressOf SystemMenuClick
                        '    End If
                        'End If
                    End With
                Next
            End If
        Catch ex As Exception
            MsgBox("LoadAPFileMenu:" + ex.ToString, MsgBoxStyle.Exclamation + MsgBoxStyle.OkOnly, Msg.CompanyName)
        End Try

    End Sub
    ''' <summary>
    ''' The GL File Menu
    ''' </summary>
    ''' <remarks></remarks>
    Private Sub LoadGLFileMenu()

        Try
            Dim Rows() As DataRow = mDataset.Tables(0).Select("ParentID=53")
            Dim mValue As System.Windows.Forms.ToolStripMenuItem
            Dim img As System.Drawing.Image
            Dim MenuPicture As String = ""
            Dim MapPath As String = ""
            If Rows.Length > 0 Then
                For Each mRow As DataRow In Rows
                    With Me.GLToolStripMenuItem.DropDownItems
                        mValue = New System.Windows.Forms.ToolStripMenuItem
                        MenuPicture = mDecrypt.DataDecrypt(mRow("ControlPicture").ToString.Replace("^", "'") & "")
                        MapPath = Application.StartupPath + "\pic\" + MenuPicture
                        If mIndex = 90 Then
                            mIndex = 64
                            IsTran = True
                        End If
                        mIndex += 1
                        mValue.Name = mRow("ControlName")
                        mValue.Tag = mRow("ID")
                        mValue.Text = mRow("ModeName")
                        If File.Exists(MapPath) Then
                            img = Image.FromFile(MapPath)
                            mValue.Image = img
                        End If
                        If IsTran = True Then
                            mValue.ShortcutKeys = Keys.Control + Keys.Alt + Asc(Chr(mIndex))
                        Else
                            mValue.ShortcutKeys = Keys.Alt + Asc(Chr(mIndex))
                        End If
                        .Add(mValue)
                        AddHandler mValue.Click, AddressOf SystemMenuClick

                        'If UserDataSet.Tables(0).Rows.Count > 0 Then
                        '    Dim ModeName As String = UserDataSet.Tables(0).Rows(0).Item("ModeName") & ""
                        '    If ModeName.IndexOf(mValue.Name) > -1 Then
                        '        .Add(mValue)
                        '        AddHandler mValue.Click, AddressOf SystemMenuClick
                        '    End If
                        'End If
                    End With
                Next
            End If
        Catch ex As Exception
            MsgBox("LoadGLFileMenu:" + ex.ToString, MsgBoxStyle.Exclamation + MsgBoxStyle.OkOnly, Msg.CompanyName)
        End Try

    End Sub
    ''' <summary>
    ''' The System Menu
    ''' </summary>
    ''' <remarks></remarks>
    Private Sub LoadSystemFileMenu()
        Try
            Dim Rows() As DataRow = mDataset.Tables(0).Select("ParentID=57")
            Dim mValue As System.Windows.Forms.ToolStripMenuItem
            Dim img As System.Drawing.Image
            Dim MenuPicture As String = ""
            Dim MapPath As String = ""
            If Rows.Length > 0 Then
                For Each mRow As DataRow In Rows
                    With Me.SystemToolStripMenuItem.DropDownItems
                        mValue = New System.Windows.Forms.ToolStripMenuItem
                        MenuPicture = mDecrypt.DataDecrypt(mRow("ControlPicture").ToString.Replace("^", "'") & "")
                        MapPath = Application.StartupPath + "\pic\" + MenuPicture
                        If mIndex = 90 Then
                            mIndex = 64
                            IsTran = True
                        End If
                        mIndex += 1
                        mValue.Name = mRow("ControlName")
                        mValue.Tag = mRow("ID")
                        mValue.Text = mRow("ModeName")
                        If File.Exists(MapPath) Then
                            img = Image.FromFile(MapPath)
                            mValue.Image = img
                        End If
                        If IsTran = True Then
                            mValue.ShortcutKeys = Keys.Control + Keys.Alt + Asc(Chr(mIndex))
                        Else
                            mValue.ShortcutKeys = Keys.Alt + Asc(Chr(mIndex))
                        End If
                        .Add(mValue)
                        AddHandler mValue.Click, AddressOf SystemMenuClick

                        'If UserDataSet.Tables(0).Rows.Count > 0 Then
                        '    Dim ModeName As String = UserDataSet.Tables(0).Rows(0).Item("ModeName") & ""
                        '    If ModeName.IndexOf(mValue.Name) > -1 Then
                        '        .Add(mValue)
                        '        AddHandler mValue.Click, AddressOf SystemMenuClick
                        '    End If
                        'End If
                    End With
                Next
            End If

        Catch ex As Exception
            Throw ex
        End Try
    End Sub

#End Region

#End Region
#Region " Button Deletegte 用來處理按鈕的點擊事件 "

    Private Sub PrepareButton()
        For Each tab As TabPage In Me.TabControl2.TabPages
            For Each col As Control In tab.Controls
                AddButtonCilckEvent(col)
            Next
        Next
    End Sub
    Private Sub AddButtonCilckEvent(ByVal col As Control)
        If TypeOf col Is Button Then
            AddHandler col.Click, AddressOf SystemButtonClick
        Else
            For Each col1 As Control In col.Controls
                If TypeOf col1 Is Button Then
                    AddHandler col1.Click, AddressOf SystemButtonClick
                Else
                    AddButtonCilckEvent(col1)
                End If
            Next
        End If
    End Sub
    Private Sub SystemButtonClick(ByVal sender As Object, ByVal e As EventArgs)
        Try
            If sender Is Nothing Then
                Exit Sub
            End If
            Dim btn As Button = CType(sender, Button)
            If btn Is Nothing Then
                Exit Sub
            End If
            If btn.Tag Is Nothing Then
                Exit Sub
            End If
            Dim ControlName As String = btn.Tag.ToString()

            Dim rows() As DataRow = ModeControls.Select("ControlName='" + ControlName + "'")

            '沒有權限進入此界面
            If rows.Length = 0 Then
                Msg.MsgError("模塊設置錯誤,或者您沒有權限進入此模塊")
                Exit Sub
            End If

            '如果沒有控制台介面，則添加
            If Not Me.TabControl1.TabPages.Contains(Me.TabPage2) Then
                Me.TabControl1.TabPages.Add(Me.TabPage2)
            End If
            Me.TabControl1.SelectedIndex = 1
            If ActionHelp = IDServer.IDServer.ActionBtn.ActionAdd Or ActionHelp = IDServer.IDServer.ActionBtn.ActionEdit Then
            Else
                Me.Panel4.Controls.Clear()
                GetPurview(ControlName)
                Dim mType As Type = Type.GetType("Tingpoo." & ControlName)
                If mType Is Nothing Then
                    MsgBox(Msg.UnComplete, MsgBoxStyle.Information + MsgBoxStyle.OkOnly, Msg.CompanyName)
                    Exit Sub
                End If
                Dim FrmName As Object = Activator.CreateInstance(mType)
                Try
                    CType(FrmName, UserControl).Dock = DockStyle.Fill
                    Me.Panel4.Controls.Add(FrmName)
                    FrmName.selectobject = Me
                    Me.SelectObject = FrmName
                    '如果ActionAdd方法沒有實現，則設置新增按鈕不可用
                    App.AddEnable = App.AddEnable And isInterfaceMethodFinished(FrmName)
                    App.PrintEnable = App.PrintEnable And isInterfaceMethodFinished(FrmName, "ActionPrint")
                Catch ex As Exception
                    MsgBox(My.Resources.LoadFormError & ex.Message, MsgBoxStyle.Critical + MsgBoxStyle.OkOnly, Msg.CompanyName)
                Finally
                    FrmName = Nothing
                End Try
                Me.ToolStrip2.Items(10).Text = sender.text
                GetToolEnable()
            End If
        Catch ex As Exception
            MsgBox(My.Resources.LoadFormError, MsgBoxStyle.Critical + MsgBoxStyle.OkOnly, Msg.CompanyName)
        End Try
    End Sub

#End Region
#Region " Windows Events "

    ''' <summary>
    ''' The Menu Deletegte
    ''' </summary>
    ''' <param name="sender"></param>
    ''' <param name="e"></param>
    ''' <remarks></remarks>
    Private Sub SystemMenuClick(ByVal sender As Object, ByVal e As EventArgs)
        Try
            '如果沒有控制台介面，則添加
            If Not Me.TabControl1.TabPages.Contains(Me.TabPage2) Then
                Me.TabControl1.TabPages.Add(Me.TabPage2)
            End If
            Me.TabControl1.SelectedIndex = 1
            If ActionHelp = IDServer.IDServer.ActionBtn.ActionAdd Or ActionHelp = IDServer.IDServer.ActionBtn.ActionEdit Then
            Else
                Me.Panel4.Controls.Clear()
                GetPurview(sender.Name)
                Dim mType As Type = Type.GetType("Tingpoo." & sender.Name)
                If mType Is Nothing Then
                    MsgBox(Msg.UnComplete, MsgBoxStyle.Information + MsgBoxStyle.OkOnly, Msg.CompanyName)
                    Exit Sub
                End If
                Dim FrmName As Object = Activator.CreateInstance(mType)
                Try
                    CType(FrmName, UserControl).Dock = DockStyle.Fill
                    Me.Panel4.Controls.Add(FrmName)
                    FrmName.selectobject = Me
                    Me.SelectObject = FrmName

                    '如果ActionAdd方法沒有實現，則設置新增按鈕不可用
                    App.AddEnable = App.AddEnable And isInterfaceMethodFinished(FrmName)
                    App.PrintEnable = App.PrintEnable And isInterfaceMethodFinished(FrmName, "ActionPrint")
                Catch ex As Exception
                    MsgBox(My.Resources.LoadFormError & ex.Message, MsgBoxStyle.Critical + MsgBoxStyle.OkOnly, Msg.CompanyName)
                Finally
                    FrmName = Nothing
                End Try

                Me.ToolStrip2.Items(10).Text = sender.text
                GetToolEnable()
            End If
        Catch ex As Exception
            MsgBox(My.Resources.LoadFormError, MsgBoxStyle.Critical + MsgBoxStyle.OkOnly, Msg.CompanyName)
        End Try
    End Sub

    ''' <summary>
    '''Load Left Side Menu
    ''' </summary>
    ''' <remarks></remarks>
    Private Sub LoadUltraListGroupBar()


        Try
            Dim sql As String = ""
            Dim mKey As String = ""
            Dim mText As String = ""
            Dim fKey As String = ""
            Dim fText As String = ""
            Dim mDecrypt As New IDSecurity
            Dim img As System.Drawing.Image
            Dim GroupImge As System.Drawing.Image
            Dim mGroup As Infragistics.Win.UltraWinListBar.Group
            Dim fItem As Infragistics.Win.UltraWinListBar.Item
            Dim GroupImagePath As String = ""
            Dim strPath As String = ""
            Dim ItemPicture As String = ""
            sql = " select distinct ID,ModeNo,ModeName,ControlName,ControlPicture,ParentId from "
            sql += "(select * from Sys_ModeDefine where ParentID=0" & vbCrLf
            sql += "union all " & vbCrLf
            sql += "select a.*  from Sys_ModeDefine a left join Sys_Action b on a.ModeNo=b.ModeID " & vbCrLf
            sql += "where b.ActionSee=1 and b.GroupID='" & PubGroupID & "') a"

            mDataset = New DataSet
            mDataset = ReturnDataset(sql)
            ModeControls = mDataset.Tables(0).Copy()
            'sql = "select a.GroupId, c.ActionSee,c.ActionEnable,c.ActionBrowser,c.ActionAdd,c.ModeName from Sys_UserManage a inner join Sys_Group b on a.GroupId=b.Id inner join Sys_Action c on b.Id=c.GroupID where a.UserCode='" & PubUserName & "'"
            'UserDataSet = New DataSet
            'UserDataSet = ReturnDataset(sql)

            If mDataset.Tables(0).Rows.Count > 0 Then
                Me.UltraListBar1.Groups.Clear()
                'GroupImagePath = Application.StartupPath & "\pic\GroupHeader.png"
                Dim Rows() As DataRow = mDataset.Tables(0).Select("ParentID=" & 0)
                If Rows.Length > 0 Then
                    For Each mRow As DataRow In Rows
                        'mGroup = New Infragistics.Win.UltraWinListBar.Group
                        'mKey = mRow("ModeNo")
                        'mText = mRow("ModeName")
                        'mGroup.Key = mKey
                        'mGroup.Text = mText

                        'Me.UltraListBar1.Groups.Add(mGroup)
                        'If File.Exists(GroupImagePath) Then
                        '    GroupImge = Image.FromFile(GroupImagePath)
                        'End If

                        Dim fRows() As DataRow = mDataset.Tables(0).Select("ParentID=" & mRow("ID"))
                        If fRows.Length > 0 Then
                            '只添加含有子項的
                            mGroup = New Infragistics.Win.UltraWinListBar.Group
                            mKey = mRow("ModeNo")
                            mText = mRow("ModeName")
                            mGroup.Key = mKey
                            mGroup.Text = mText

                            Me.UltraListBar1.Groups.Add(mGroup)
                            If File.Exists(GroupImagePath) Then
                                GroupImge = Image.FromFile(GroupImagePath)
                            End If

                            For Each fRow As DataRow In fRows
                                With mGroup.Items
                                    fItem = New Infragistics.Win.UltraWinListBar.Item
                                    ItemPicture = mDecrypt.DataDecrypt(fRow("ControlPicture").ToString.Replace("^", "'") & "")
                                    strPath = Application.StartupPath + "\pic\" + ItemPicture
                                    If File.Exists(strPath) Then
                                        img = Image.FromFile(strPath)
                                        fItem.Appearance.Image = img
                                    End If
                                    fItem.Key = fRow("ControlName")
                                    fItem.Tag = fRow("ControlName")
                                    fItem.Text = fRow("ModeName")
                                    .Add(fItem)
                                    'If UserDataSet.Tables(0).Rows.Count > 0 Then
                                    '    Dim ModeName As String = UserDataSet.Tables(0).Rows(0).Item("ModeName") & ""
                                    '    If ModeName.IndexOf(fItem.Key) > -1 Then
                                    '        .Add(fItem)
                                    '    End If
                                    'End If
                                End With
                            Next
                        End If
                    Next
                End If
            End If
            Me.UltraListBar1.Appearance.BackColor = Color.White
            Me.UltraListBar1.Appearance.BackColor2 = Color.Gray
            Me.UltraListBar1.Appearance.BackGradientStyle = Win.GradientStyle.Vertical
        Catch ex As Exception
            MsgBox("LoadUltraListGroupBar:" + ex.ToString, MsgBoxStyle.Critical + MsgBoxStyle.OkOnly, Msg.CompanyName)
        Finally

        End Try
    End Sub

    ''' <summary>
    ''' The Toolbar Enabled
    ''' </summary>
    ''' <param name="bFind"></param>
    ''' <remarks></remarks>
    Public Sub BtnEnable(ByVal bFind As Boolean)
        Try
            Me.ToolStripAdd.Enabled = ActionHelp = IDServer.IDServer.ActionBtn.ActionHelp
            Me.ToolStripEdit.Enabled = ActionHelp = IDServer.IDServer.ActionBtn.ActionHelp And bFind = True
            Me.ToolStripDelete.Enabled = ActionHelp = IDServer.IDServer.ActionBtn.ActionHelp And bFind = True
            Me.ToolStripSave.Enabled = mBool = True And (ActionHelp = IDServer.IDServer.ActionBtn.ActionAdd Or ActionHelp = IDServer.IDServer.ActionBtn.ActionEdit)
            Me.ToolStripCancel.Enabled = mBool = True And (ActionHelp = IDServer.IDServer.ActionBtn.ActionAdd Or ActionHelp = IDServer.IDServer.ActionBtn.ActionEdit)
            Me.ToolStripImport.Enabled = bFind
            Me.ToolStripFilter.Enabled = bFind
            Me.ToolStripExport.Enabled = bFind
            Me.ToolStripPrint.Enabled = bFind
            Me.ToolStripFirst.Enabled = mBool = True And ActionHelp = IDServer.IDServer.ActionBtn.ActionHelp
            Me.ToolStripPrivous.Enabled = mBool
            Me.ToolStripNext.Enabled = mBool
            Me.ToolStripLast.Enabled = mBool

            Me.AddToolStripMenuItem.Enabled = Me.ToolStripAdd.Enabled
            Me.Edit1ToolStripMenuItem.Enabled = Me.ToolStripEdit.Enabled
            Me.DelToolStripMenuItem.Enabled = Me.ToolStripDelete.Enabled
            Me.SaveToolStripMenuItem.Enabled = Me.ToolStripSave.Enabled
            Me.CancelToolStripMenuItem.Enabled = Me.ToolStripCancel.Enabled
            Me.PrintToolStripMenuItem.Enabled = Me.ToolStripPrint.Enabled
            Me.ExportToolStripMenuItem.Enabled = Me.ToolStripImport.Enabled
            Me.ImportToolStripMenuItem.Enabled = Me.ToolStripExport.Enabled
            Me.FilterToolStripMenuItem.Enabled = Me.ToolStripFilter.Enabled
        Catch ex As Exception
            MsgBox("BtnEnable" + ex.ToString, MsgBoxStyle.Critical + MsgBoxStyle.OkOnly, Msg.CompanyName)
        End Try
    End Sub

    ''' <summary>
    ''' 
    ''' </summary>
    ''' <remarks></remarks>
    Private Sub GetToolEnable()
        Try
            With Me
                .ToolStripAdd.Enabled = AddEnable
                .ToolStripEdit.Enabled = False
                .ToolStripDelete.Enabled = False
                .ToolStripPrint.Enabled = False
                .ToolStripImport.Enabled = False
                .ToolStripExport.Enabled = False
                .ToolStripFind.Enabled = FindEnable
                .ToolStripCheck.Enabled = False
                .ToolStripUnCheck.Enabled = False
                .ToolStripComplete.Enabled = False
                .AddToolStripMenuItem.Enabled = .ToolStripAdd.Enabled
                .Edit1ToolStripMenuItem.Enabled = .ToolStripEdit.Enabled
                .DelToolStripMenuItem.Enabled = .ToolStripDelete.Enabled
                .PrintToolStripMenuItem.Enabled = .ToolStripPrint.Enabled
                .ExportToolStripMenuItem.Enabled = .ToolStripImport.Enabled
                .ImportToolStripMenuItem.Enabled = .ToolStripExport.Enabled
                .FilterToolStripMenuItem.Enabled = .ToolStripFilter.Enabled
            End With

        Catch ex As Exception
            MsgBox("TreeView1_AfterSelect:" + ex.ToString, MsgBoxStyle.Critical + MsgBoxStyle.OkOnly, Msg.CompanyName)
        End Try
    End Sub

    ''' <summary>
    ''' The Form Close Event
    ''' </summary>
    ''' <param name="sender"></param>
    ''' <param name="e"></param>
    ''' <remarks></remarks>
    Private Sub Frm_MainForm_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
        Try
            If ask = False Then
                If MsgBox(My.Resources.AreYouSureExist, MsgBoxStyle.Question + MsgBoxStyle.OkCancel, Msg.CompanyName) = MsgBoxResult.Ok Then
                    ask = True
                    e.Cancel = False
                    LoginInfo(1)
                    Application.Exit()
                Else
                    e.Cancel = True
                End If
            Else
                LoginInfo(1)
                Application.Exit()
            End If

        Catch ex As Exception
            Throw ex
        End Try
    End Sub

    Private Sub LoadTree(ByVal Tv As TreeView)
        Try
            Dim Node As New TreeNode
            Dim SQL As String = "select * from dbo.Sys_ModeDefine "
            Tv.Nodes.Clear()
            Node.Tag = "ALL"
            Node.Text = "所有模塊"
            Tv.Nodes.Add(Node)
            mDataset = New DataSet
            mDataset = ReturnDataset(SQL)
            SelectDS = mDataset.Copy
            LoadSecondTree(Node, 0)
            SelectNode = Node
            Node.Expand()
        Catch ex As Exception
            MsgBox("LoadTree:" + ex.ToString, MsgBoxStyle.Critical + MsgBoxStyle.OkOnly, Msg.CompanyName)
        End Try
    End Sub

    Private Sub LoadSecondTree(ByVal TreeNode As TreeNode, ByVal ParentId As Integer)
        Try
            If mDataset Is Nothing Then Exit Sub
            Dim Rows() As DataRow = mDataset.Tables(0).Select("ParentId=" & ParentId)
            Dim Define As Int16 = 0
            For Each mRow As DataRow In Rows
                Dim mNode As New TreeNode
                If TreeNode Is Nothing Then
                    mNode.Tag = mRow("ID")
                    mNode.Text = mRow("modename")
                    mNode.ImageIndex = 0
                    TreeNode.Nodes.Add(mNode)
                    mNode.Expand()
                    LoadSecondTree(mNode, mRow("ID"))
                Else
                    mNode.Tag = mRow("ID")
                    mNode.Text = mRow("modename")
                    If Define = 0 Then
                        mNode.ImageIndex = 1
                        mNode.SelectedImageIndex = 2
                    ElseIf Define = 1 Then
                        mNode.ImageIndex = 3
                        mNode.SelectedImageIndex = 4
                    ElseIf Define = 2 Then
                        mNode.ImageIndex = 5
                        mNode.SelectedImageIndex = 6
                    End If
                    TreeNode.Nodes.Add(mNode)
                    mNode.Expand()
                    LoadSecondTree(mNode, mRow("ID"))
                End If
            Next
        Catch ex As Exception
            Throw ex
        End Try
    End Sub

    ''' <summary>
    ''' The Form Load Event
    ''' </summary>
    ''' <param name="sender"></param>
    ''' <param name="e"></param>
    ''' <remarks></remarks>
    Private Sub Frm_MainForm_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        Try
            LoadTree(Me.TreeView1)
            LoadUltraListGroupBar()
            LoadToolScriptItem(Me.ToolStrip2)
            LoadAllFileMenu()
            'LoadBasicFileMenu()
            'LoadSaleFileMenu()
            'LoadOrdeFileMenu()
            'LoadStoreFileMenu()
            'LoadARFileMenu()
            'LoadAPFileMenu()
            'LoadGLFileMenu()
            'LoadSystemFileMenu()
            PrepareButton()
            BtnEnable(False)
            Me.ToolStripAdd.Enabled = False
            Me.AddToolStripMenuItem.Enabled = Me.ToolStripAdd.Enabled
            Me.ToolStripFind.Enabled = False
            Me.ToolStripCheck.Enabled = False
            Me.ToolStripUnCheck.Enabled = False
            Me.ToolStripComplete.Enabled = False
            Me.FindToolStripMenuItem.Enabled = False
            Me.ToolStripCheck.Enabled = False
            Me.ToolStripUnCheck.Enabled = False
            Me.IntialHashtable = AddpagetoHash()
            '去掉控制台顯示卡
            If Me.TabControl1.TabPages.Contains(Me.TabPage2) Then
                Me.TabControl1.TabPages.Remove(Me.TabPage2)
            End If
            Me.TabControl2.TabPages.Clear()
            '顯示基礎資料的介面
            Me.TabControl2.TabPages.Add(Me.Tab2_1)


        Catch ex As Exception
            MsgBox("加載窗體出錯！", MsgBoxStyle.Critical + MsgBoxStyle.OkOnly, Msg.CompanyName)
            WriteApplicationLog("Frm_MainForm_Load" & ex.ToString, EventType.Error)
        Finally
            mDataset.Dispose()
            UserDataSet = Nothing
            mDataset = Nothing
        End Try
    End Sub


    ''' <summary>
    ''' 
    ''' </summary>
    ''' <param name="sender"></param>
    ''' <param name="e"></param>
    ''' <remarks></remarks>
    Private Sub UltraListBar1_ItemSelected(ByVal sender As Object, ByVal e As Infragistics.Win.UltraWinListBar.ItemEventArgs) Handles UltraListBar1.ItemSelected
        Try
            If ActionHelp = IDServer.IDServer.ActionBtn.ActionAdd Or ActionHelp = IDServer.IDServer.ActionBtn.ActionEdit Then
            Else
                '如果沒有控制台介面，則添加
                If Not Me.TabControl1.TabPages.Contains(Me.TabPage2) Then
                    Me.TabControl1.TabPages.Add(Me.TabPage2)
                End If
                Me.TabControl1.SelectedIndex = 1
                Me.Panel4.Controls.Clear()
                SelectObject = Nothing
                GetPurview(e.Item.Key)
                Dim mType As Type = Type.GetType("Tingpoo." & e.Item.Key)
                If mType Is Nothing Then
                    MsgBox(Msg.UnComplete, MsgBoxStyle.Information + MsgBoxStyle.OkOnly, Msg.CompanyName)
                    Exit Sub
                End If
                Dim FrmName As Object = Activator.CreateInstance(mType)
                Try
                    CType(FrmName, UserControl).Dock = DockStyle.Fill
                    Me.Panel4.Controls.Add(FrmName)
                    FrmName.selectobject = Me
                    Me.SelectObject = FrmName
                    If str_language.ToString.ToString.Length <= 0 Then
                        str_language = Msg.Systemdefaultlanguage
                    End If                    System.Threading.Thread.CurrentThread.CurrentUICulture = System.Globalization.CultureInfo.GetCultureInfo(App.str_language)
                    App.AddEnable = App.AddEnable And isInterfaceMethodFinished(FrmName)
                    App.PrintEnable = App.PrintEnable And isInterfaceMethodFinished(FrmName, "ActionPrint")
                Catch ex As Exception
                    MsgBox("對不起，加載模塊出錯！" & ex.Message, MsgBoxStyle.Exclamation + MsgBoxStyle.OkOnly, Msg.CompanyName)
                Finally
                    FrmName = Nothing
                End Try
                Me.ToolStrip2.Items(10).Text = e.Item.Text
                GetToolEnable()
            End If
        Catch ex As Exception
            MsgBox(My.Resources.ErrorOperate, MsgBoxStyle.Information + MsgBoxStyle.OkOnly, Msg.CompanyName)
        Finally

        End Try
    End Sub


    Private Sub ProgressInfo()

        Try
            CType(Me.ToolStrip2.Items(12), System.Windows.Forms.ToolStripProgressBar).Invalidate()
            For i As Integer = 0 To 100
                CType(Me.ToolStrip2.Items(12), System.Windows.Forms.ToolStripProgressBar).PerformStep()
            Next
            'CType(Me.ToolStrip2.Items(12), System.Windows.Forms.ToolStripProgressBar).
        Catch ex As Exception
            MsgBox(My.Resources.ErrorOperate, MsgBoxStyle.Information + MsgBoxStyle.OkOnly, Msg.CompanyName)
        Finally

        End Try

    End Sub

#End Region
#Region " ToolStripClick "

    ''' <summary>
    ''' add 
    ''' </summary>
    ''' <param name="sender"></param>
    ''' <param name="e"></param>
    ''' <remarks></remarks>
    Public Sub ToolStripAdd_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles ToolStripAdd.Click
        Try
            mBool = True
            ActionHelp = IDServer.IDServer.ActionBtn.ActionAdd
            Me.SelectObject.ActionAdd()
        Catch ex As Exception
            MsgBox(My.Resources.ErrorOperate, MsgBoxStyle.Critical + MsgBoxStyle.OkOnly, Msg.CompanyName)
            WriteApplicationLog("ToolStripAdd_Click" & ex.Message, EventType.Failure)
        End Try
    End Sub

    ''' <summary>
    ''' cancel
    ''' </summary>
    ''' <param name="sender"></param>
    ''' <param name="e"></param>
    ''' <remarks></remarks>
    Public Sub ToolStripCancel_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles ToolStripCancel.Click
        Try
            ActionHelp = IDServer.IDServer.ActionBtn.ActionHelp
            Me.SelectObject.ActionCancel()
        Catch ex As Exception
            MsgBox(My.Resources.ErrorOperate, MsgBoxStyle.Critical + MsgBoxStyle.OkOnly, Msg.CompanyName)
            WriteApplicationLog("ToolStripCancel_Click" & ex.Message, EventType.Failure)
        End Try
    End Sub

    ''' <summary>
    ''' check
    ''' </summary>
    ''' <param name="sender"></param>
    ''' <param name="e"></param>
    ''' <remarks></remarks>
    Public Sub ToolStripCheck_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles ToolStripCheck.Click
        Me.SelectObject.ActionChecked()
    End Sub

    ''' <summary>
    ''' complete
    ''' </summary>
    ''' <param name="sender"></param>
    ''' <param name="e"></param>
    ''' <remarks></remarks>
    Public Sub ToolStripComplete_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles ToolStripComplete.Click

    End Sub

    ''' <summary>
    ''' delete
    ''' </summary>
    ''' <param name="sender"></param>
    ''' <param name="e"></param>
    ''' <remarks></remarks>
    Public Sub ToolStripDelete_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles ToolStripDelete.Click
        Try

            ActionHelp = IDServer.IDServer.ActionBtn.ActionHelp
            Me.SelectObject.ActionDelete()
        Catch ex As Exception
            MsgBox(My.Resources.ErrorOperate, MsgBoxStyle.Critical + MsgBoxStyle.OkOnly, Msg.CompanyName)
            WriteApplicationLog("ToolStripDelete_Click" & ex.Message, EventType.Failure)
        End Try

    End Sub

    ''' <summary>
    ''' edit
    ''' </summary>
    ''' <param name="sender"></param>
    ''' <param name="e"></param>
    ''' <remarks></remarks>
    Public Sub ToolStripEdit_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles ToolStripEdit.Click
        Try
            mBool = True
            ActionHelp = IDServer.IDServer.ActionBtn.ActionEdit
            Me.SelectObject.ActionEdit()
        Catch ex As Exception
            MsgBox(My.Resources.ErrorOperate, MsgBoxStyle.Critical + MsgBoxStyle.OkOnly, Msg.CompanyName)
            WriteApplicationLog("ToolStripEdit_Click" & ex.Message, EventType.Failure)
        End Try
    End Sub

    ''' <summary>
    ''' exit
    ''' </summary>
    ''' <param name="sender"></param>
    ''' <param name="e"></param>
    ''' <remarks></remarks>
    Public Sub ToolStripExist_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles ToolStripExist.Click
        Try
            If ActionHelp = IDServer.IDServer.ActionBtn.ActionAdd Or ActionHelp = IDServer.IDServer.ActionBtn.ActionEdit Then
                If MsgBox("數據已改變，是否存檔！", MsgBoxStyle.Question + MsgBoxStyle.YesNo, Msg.CompanyName) = MsgBoxResult.Yes Then
                    ToolStripSave_Click(Nothing, Nothing)
                Else
                    Application.Exit()
                End If
            Else
                Application.Exit()
            End If
            WriteApplicationLog(PubUserCode & "已退出KRSOFT", EventType.Information)
        Catch ex As Exception
            MsgBox(My.Resources.ErrorOperate, MsgBoxStyle.Critical + MsgBoxStyle.OkOnly, Msg.CompanyName)
            WriteApplicationLog("ToolStripExist_Click" & ex.Message, EventType.Failure)
        End Try
    End Sub

    ''' <summary>
    ''' import
    ''' </summary>
    ''' <param name="sender"></param>
    ''' <param name="e"></param>
    ''' <remarks></remarks>
    Public Sub ToolStripImport_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles ToolStripImport.Click
        Try
            'ActionHelp = IDServer.IDServer.ActionBtn.ActionHelp
            Me.SelectObject.ActionImport()
        Catch ex As Exception
            MsgBox(My.Resources.ErrorOperate, MsgBoxStyle.Critical + MsgBoxStyle.OkOnly, Msg.CompanyName)
            WriteApplicationLog("ToolStripImport_Click" & ex.Message, EventType.Failure)
        End Try
    End Sub

    ''' <summary>
    ''' filter
    ''' </summary>
    ''' <param name="sender"></param>
    ''' <param name="e"></param>
    ''' <remarks></remarks>
    Public Sub ToolStripFilter_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles ToolStripFilter.Click
        Try
            'ActionHelp = IDServer.IDServer.ActionBtn.ActionHelp
            Me.SelectObject.ActionFilter()
        Catch ex As Exception
            MsgBox(My.Resources.ErrorOperate, MsgBoxStyle.Critical + MsgBoxStyle.OkOnly, Msg.CompanyName)
            WriteApplicationLog("ToolStripFilter_Click" & ex.Message, EventType.Failure)
        End Try
    End Sub

    ''' <summary>
    ''' find
    ''' </summary>
    ''' <param name="sender"></param>
    ''' <param name="e"></param>
    ''' <remarks></remarks>
    Public Sub ToolStripFind_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles ToolStripFind.Click
        Try
            'ActionHelp = IDServer.IDServer.ActionBtn.ActionHelp
            Me.SelectObject.ActionSelect()

        Catch ex As Exception
            MsgBox(My.Resources.ErrorOperate, MsgBoxStyle.Critical + MsgBoxStyle.OkOnly, Msg.CompanyName)
            WriteApplicationLog("ToolStripFind_Click" & ex.Message, EventType.Failure)
        End Try
    End Sub

    ''' <summary>
    ''' the first
    ''' </summary>
    ''' <param name="sender"></param>
    ''' <param name="e"></param>
    ''' <remarks></remarks>
    Public Sub ToolStripFirst_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles ToolStripFirst.Click
        Try
            'ActionHelp = IDServer.IDServer.ActionBtn.ActionHelp
            Me.SelectObject.ActionGoFirst()
        Catch ex As Exception
            MsgBox(My.Resources.ErrorOperate, MsgBoxStyle.Critical + MsgBoxStyle.OkOnly, Msg.CompanyName)
            WriteApplicationLog("ToolStripFirst_Click" & ex.Message, EventType.Failure)
        End Try
    End Sub

    ''' <summary>
    ''' export
    ''' </summary>
    ''' <param name="sender"></param>
    ''' <param name="e"></param>
    ''' <remarks></remarks>
    Public Sub ToolStripExport_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles ToolStripExport.Click
        Try
            'ActionHelp = IDServer.IDServer.ActionBtn.ActionHelp
            Me.SelectObject.ActionExport()
        Catch ex As Exception
            MsgBox(My.Resources.ErrorOperate, MsgBoxStyle.Critical + MsgBoxStyle.OkOnly, Msg.CompanyName)
            WriteApplicationLog("ToolStripExport_Click" & ex.Message, EventType.Failure)
        End Try
    End Sub

    ''' <summary>
    ''' the last
    ''' </summary>
    ''' <param name="sender"></param>
    ''' <param name="e"></param>
    ''' <remarks></remarks>
    Public Sub ToolStripLast_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles ToolStripLast.Click
        Try
            'ActionHelp = IDServer.IDServer.ActionBtn.ActionHelp
            Me.SelectObject.ActionGoLast()
        Catch ex As Exception
            MsgBox(My.Resources.ErrorOperate, MsgBoxStyle.Critical + MsgBoxStyle.OkOnly, Msg.CompanyName)
            WriteApplicationLog("ToolStripLast_Click" & ex.Message, EventType.Failure)
        End Try
    End Sub

    ''' <summary>
    ''' the next
    ''' </summary>
    ''' <param name="sender"></param>
    ''' <param name="e"></param>
    ''' <remarks></remarks>
    Public Sub ToolStripNext_Click1(ByVal sender As Object, ByVal e As System.EventArgs) Handles ToolStripNext.Click
        Try
            'ActionHelp = IDServer.IDServer.ActionBtn.ActionHelp
            Me.SelectObject.ActionGoNext()
        Catch ex As Exception
            MsgBox(My.Resources.ErrorOperate, MsgBoxStyle.Critical + MsgBoxStyle.OkOnly, Msg.CompanyName)
            WriteApplicationLog("ToolStripNext_Click1" & ex.Message, EventType.Failure)
        End Try
    End Sub

    ''' <summary>
    ''' the privous
    ''' </summary>
    ''' <param name="sender"></param>
    ''' <param name="e"></param>
    ''' <remarks></remarks>
    Public Sub ToolStripPrivous_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles ToolStripPrivous.Click
        Try

            'ActionHelp = IDServer.IDServer.ActionBtn.ActionHelp
            Me.SelectObject.ActionGoPrevious()
        Catch ex As Exception
            MsgBox(My.Resources.ErrorOperate, MsgBoxStyle.Critical + MsgBoxStyle.OkOnly, Msg.CompanyName)
            WriteApplicationLog("ToolStripPrivous_Click" & ex.Message, EventType.Failure)
        End Try
    End Sub

    ''' <summary>
    ''' print
    ''' </summary>
    ''' <param name="sender"></param>
    ''' <param name="e"></param>
    ''' <remarks></remarks>
    Public Sub ToolStripPrint_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles ToolStripPrint.Click
        Try
            'ActionHelp = IDServer.IDServer.ActionBtn.ActionHelp
            Me.SelectObject.ActionPrint()
        Catch ex As Exception
            MsgBox(My.Resources.ErrorOperate, MsgBoxStyle.Critical + MsgBoxStyle.OkOnly, Msg.CompanyName)
            WriteApplicationLog("ToolStripPrint_Click" & ex.Message, EventType.Failure)
        End Try
    End Sub

    ''' <summary>
    ''' save
    ''' </summary>
    ''' <param name="sender"></param>
    ''' <param name="e"></param>
    ''' <remarks></remarks>
    Public Sub ToolStripSave_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles ToolStripSave.Click
        Try

            ActionHelp = IDServer.IDServer.ActionBtn.ActionHelp
            If Me.SelectObject.ActionSave() = True Then
            End If
        Catch ex As Exception
            MsgBox(My.Resources.ErrorOperate, MsgBoxStyle.Critical + MsgBoxStyle.OkOnly, Msg.CompanyName)
            WriteApplicationLog("ToolStripSave_Click" & ex.Message, EventType.Failure)
        End Try
    End Sub

    ''' <summary>
    ''' update
    ''' </summary>
    ''' <param name="sender"></param>
    ''' <param name="e"></param>
    ''' <remarks></remarks>
    Public Sub ToolStripUpdate_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles ToolStripUpdate.Click

        Dim Frm_Update As New Frm_Update
        Dim sql As String = ""
        Dim mDs As New DataSet
        Try
            sql = "select  *  from Sys_ModeDefine"
            mDs = ReturnDataset(sql)

            LoadUltraListGroupBar()
            Frm_Update.Show()
            Frm_Update.ProgressBar1.Maximum = mDs.Tables(0).Rows.Count
            Frm_Update.ProgressBar1.Minimum = 1
            Frm_Update.ProgressBar1.Value = 1
            Frm_Update.ProgressBar1.Step = 1
            For i As Integer = 0 To mDs.Tables(0).Rows.Count - 1
                Frm_Update.ProgressBar1.PerformStep()
                Frm_Update.ProgressBar1.Refresh()
            Next
            Frm_Update.Close()
            ActionHelp = IDServer.IDServer.ActionBtn.ActionHelp
        Catch ex As Exception
            MsgBox("ToolStripUpdate_Click:" + ex.ToString, MsgBoxStyle.Critical + MsgBoxStyle.OkOnly, Msg.CompanyName)
            WriteApplicationLog("ToolStripUpdate_Click" & ex.Message, EventType.Failure)
        Finally
            Frm_Update.Dispose()
            mDs.Dispose()
            mDs = Nothing
        End Try
    End Sub

    ''' <summary>
    ''' ToolStripRegardLogin
    ''' </summary>
    ''' <param name="sender"></param>
    ''' <param name="e"></param>
    ''' <remarks></remarks>
    Private Sub ToolStripRegardLogin_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles ToolStripRegardLogin.Click
        ''Application.Restart()
        Application.Restart()
    End Sub

    ''' <summary>
    ''' MoserDown
    ''' </summary>
    ''' <param name="sender"></param>
    ''' <param name="e"></param>
    ''' <remarks></remarks>
    Private Sub Panel5_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs)
        Try
            ReleaseCapture()
            SendMessage(Me.Handle.ToInt64, WM_NCLBUTTonDOWN, HTCAPTION, 0)
        Catch ex As Exception
            MsgBox("Panel5_MouseDown:" + ex.ToString, MsgBoxStyle.Critical + MsgBoxStyle.OkOnly, Msg.CompanyName)
        End Try
    End Sub

    ''' <summary>
    ''' UnCheck
    ''' </summary>
    ''' <param name="sender"></param>
    ''' <param name="e"></param>
    ''' <remarks></remarks>
    Private Sub ToolStripUnCheck_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripUnCheck.Click
        Me.SelectObject.ActionUnChecked()
    End Sub

    ''' <summary>
    ''' AboutmeToolStripMenuItem
    ''' </summary>
    ''' <param name="sender"></param>
    ''' <param name="e"></param>
    ''' <remarks></remarks>
    Private Sub AboutmeToolStripMenuItem_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles AboutmeToolStripMenuItem.Click
        Dim AboutSys As New Frm_AboutSys
        AboutSys.ShowDialog()
    End Sub

    ''' <summary>
    ''' ReLoginToolStripMenuItem
    ''' </summary>
    ''' <param name="sender"></param>
    ''' <param name="e"></param>
    ''' <remarks></remarks>
    Private Sub ReLoginToolStripMenuItem_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles ReLoginToolStripMenuItem.Click

        Try

            Application.Restart()

        Catch ex As Exception
            MsgBox("ReLoginToolStripMenuItem_Click:", MsgBoxStyle.Exclamation + MsgBoxStyle.OkOnly, Msg.CompanyName)
        End Try

    End Sub

#End Region
#Region "File Menu"

    ''' <summary>
    ''' 
    ''' </summary>
    ''' <param name="sender"></param>
    ''' <param name="e"></param>
    ''' <remarks></remarks>
    Private Sub AddToolStripMenuItem_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles AddToolStripMenuItem.Click
        ToolStripAdd_Click(Nothing, Nothing)
    End Sub

    ''' <summary>
    ''' 
    ''' </summary>
    ''' <param name="sender"></param>
    ''' <param name="e"></param>
    ''' <remarks></remarks>
    Private Sub Edit1ToolStripMenuItem_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Edit1ToolStripMenuItem.Click
        ToolStripEdit_Click(Nothing, Nothing)
    End Sub

    ''' <summary>
    ''' 
    ''' </summary>
    ''' <param name="sender"></param>
    ''' <param name="e"></param>
    ''' <remarks></remarks>
    Private Sub DelToolStripMenuItem_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles DelToolStripMenuItem.Click
        ToolStripDelete_Click(Nothing, Nothing)
    End Sub

    ''' <summary>
    ''' 
    ''' </summary>
    ''' <param name="sender"></param>
    ''' <param name="e"></param>
    ''' <remarks></remarks>
    Private Sub SaveToolStripMenuItem_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles SaveToolStripMenuItem.Click
        ToolStripSave_Click(Nothing, Nothing)
    End Sub

    ''' <summary>
    ''' 
    ''' </summary>
    ''' <param name="sender"></param>
    ''' <param name="e"></param>
    ''' <remarks></remarks>
    Private Sub CancelToolStripMenuItem_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles CancelToolStripMenuItem.Click
        ToolStripCancel_Click(Nothing, Nothing)
    End Sub

    ''' <summary>
    ''' 
    ''' </summary>
    ''' <param name="sender"></param>
    ''' <param name="e"></param>
    ''' <remarks></remarks>
    Private Sub PrintToolStripMenuItem_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles PrintToolStripMenuItem.Click
        ToolStripPrint_Click(Nothing, Nothing)
    End Sub

    ''' <summary>
    ''' 
    ''' </summary>
    ''' <param name="sender"></param>
    ''' <param name="e"></param>
    ''' <remarks></remarks>
    Private Sub ExportToolStripMenuItem_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles ExportToolStripMenuItem.Click
        ToolStripExport_Click(Nothing, Nothing)
    End Sub

    ''' <summary>
    ''' 
    ''' </summary>
    ''' <param name="sender"></param>
    ''' <param name="e"></param>
    ''' <remarks></remarks>
    Private Sub ImportToolStripMenuItem_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles ImportToolStripMenuItem.Click
        ToolStripImport_Click(Nothing, Nothing)
    End Sub

    ''' <summary>
    ''' 
    ''' </summary>
    ''' <param name="sender"></param>
    ''' <param name="e"></param>
    ''' <remarks></remarks>
    Private Sub FilterToolStripMenuItem_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles FilterToolStripMenuItem.Click
        ToolStripFilter_Click(Nothing, Nothing)
    End Sub

    ''' <summary>
    ''' 
    ''' </summary>
    ''' <param name="sender"></param>
    ''' <param name="e"></param>
    ''' <remarks></remarks>
    Private Sub FindToolStripMenuItem_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles FindToolStripMenuItem.Click
        ToolStripFind_Click(Nothing, Nothing)
    End Sub

    ''' <summary>
    ''' 
    ''' </summary>
    ''' <param name="sender"></param>
    ''' <param name="e"></param>
    ''' <remarks></remarks>
    Private Sub ExitToolStripMenuItem_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles ExitToolStripMenuItem.Click
        ToolStripExist_Click(Nothing, Nothing)
    End Sub

#End Region
#Region "View Menu"

    Private Sub SysModeToolStripMenuItem_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles SysModeToolStripMenuItem.Click
        Me.TabControl1.SelectedIndex = 1
        Me.UltraDockManager1.ControlPanes(0).Show()
    End Sub

#End Region
#Region " Control Event "

    <System.Diagnostics.DebuggerNonUserCodeAttribute()> _
    Private Sub Panel4_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs)
        Dim mWidth As Integer = Me.Panel4.Width
        Dim mHeight As Integer = Me.Panel4.Height
        e.Graphics.SmoothingMode = Drawing2D.SmoothingMode.AntiAlias
        e.Graphics.FillRectangle(New Drawing2D.LinearGradientBrush(New Point(0, 0), New Point(mWidth, mHeight), Color.White, Color.Gray), 0, 0, mWidth, mHeight)
    End Sub
    <System.Diagnostics.DebuggerNonUserCodeAttribute()> _
    Private Sub Panel1_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles Panel1.Paint
        Dim mWidth As Integer = Me.Panel1.Width
        Dim mHeight As Integer = Me.Panel1.Height
        e.Graphics.SmoothingMode = Drawing2D.SmoothingMode.AntiAlias
        e.Graphics.FillRectangle(New Drawing2D.LinearGradientBrush(New Point(0, 0), New Point(mWidth, mHeight), Color.White, Color.Gray), 0, 0, mWidth, mHeight)
    End Sub
    <System.Diagnostics.DebuggerNonUserCodeAttribute()> _
    Private Sub ToolStrip2_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles ToolStrip2.Paint
        Dim mWidth As Integer = Me.ToolStrip2.Width
        Dim mHeight As Integer = Me.ToolStrip2.Height
        e.Graphics.SmoothingMode = Drawing2D.SmoothingMode.AntiAlias
        e.Graphics.FillRectangle(New Drawing2D.LinearGradientBrush(New Point(0, 0), New Point(mWidth, mHeight), Color.White, Color.Gray), 0, 0, mWidth, mHeight)
    End Sub
    Private Sub ListView1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ListView1.Click
        Dim reportID As String = ""
        For Each item As ListViewItem In ListView1.SelectedItems
            reportID = item.Tag.ToString()
        Next
        If Not isNull(reportID) Then
            DisPlayForm(reportID)
        End If
    End Sub
    Private Sub TreeView1_AfterSelect(ByVal sender As Object, ByVal e As System.Windows.Forms.TreeViewEventArgs) Handles TreeView1.AfterSelect
        Try
            If SelectNode Is Nothing Then Exit Sub
            SelectNode = e.Node
            Dim Nodestring As String = e.Node.Text
            If e.Action = TreeViewAction.ByKeyboard Or e.Node Is Nothing Or e.Node.Tag.ToString = "All" Then
                Exit Sub
            End If
            If SelectDS.Tables(0).Rows.Count > 0 Then
                Dim rows() As DataRow = SelectDS.Tables(0).Select("Modename='" & Nodestring & "'")
                If rows.Length > 0 Then
                    For Each row As DataRow In rows
                        Me.Txtremark.Width = Me.GroupBox2.Width
                        Me.Txtremark.Text = row("remark").ToString
                    Next
                End If

                Dim rows2() As DataRow = SelectDS.Tables(0).Select("Modename='" & Nodestring & "' and ParentID='0' ")
                If rows2.Length > 0 Then
                    Dim ModeNo As String = rows2(0)("ModeNo").ToString()
                    SetListView(ModeNo)
                    For Each row2 As DataRow In rows2
                        'For Each tab As TabPage In Me.TabControl2.TabPages
                        Select Case row2("ModeNo").ToString.ToLower
                            Case "BSC".ToLower '基礎資料
                                DynamicAddPage("Tab2_1")
                            Case "PUR".ToLower '采購管理
                                DynamicAddPage("Tab2_2")
                            Case "Sal".ToLower '銷售管理
                                DynamicAddPage("Tab2_3")
                            Case "Store".ToLower '庫存管理
                                DynamicAddPage("Tab2_4")
                            Case "AR".ToLower '應收系統
                                DynamicAddPage("Tab2_5")
                            Case "AP".ToLower '應付系統
                                DynamicAddPage("Tab2_6")
                            Case "GL".ToLower '財務系統
                                DynamicAddPage("Tab2_7")
                            Case "Sys".ToLower '系統定義
                                DynamicAddPage("Tab2_8")
                            Case "delivery".ToLower '跟單管理
                                DynamicAddPage("Tab2_9")
                            Case "lo".ToLower '物流管理
                                DynamicAddPage("Tab2_10")
                            Case "cars".ToLower '車輛管理
                                DynamicAddPage("Tab2_11")
                            Case "CS".ToLower '客服管理
                                DynamicAddPage("Tab2_12")
                            Case "Manufacture".ToLower '生產管理
                                DynamicAddPage("Tab2_13")
                        End Select
                    Next
                    'Next
                End If
            End If
        Catch ex As Exception
            MsgBox("TreeView1_AfterSelect:" + ex.ToString, MsgBoxStyle.Critical + MsgBoxStyle.OkOnly, Msg.CompanyName)
        End Try
    End Sub

#End Region
#Region " ControlPage  "

    Private Function AddpagetoHash() As Hashtable
        Dim mhast As New Hashtable
        For Each Pag As TabPage In Me.TabControl2.TabPages
            Dim Pagename As String = Pag.Name
            mhast.Add(Pagename, Pag)
        Next

        'For Each key As Object In mhast.Keys
        '    Debug.WriteLine(key.ToString() + "  " + CType(mhast.Item(key), TabPage).Text)
        'Next

        Return mhast
    End Function
    Private Function DynamicAddPage(ByVal tablename As String)
        Me.TabControl2.TabPages.Clear()
        Dim Pag As TabPage = DirectCast(Me.IntialHashtable(tablename), TabPage)
        If Not Pag Is Nothing Then
            Me.TabControl2.TabPages.Add(Pag)
        End If
    End Function

#End Region
#Region " Private Methods "

    ''' <summary>
    '''根據模塊名將報表列表填充到ListView
    ''' </summary>
    ''' <param name="ModeNo">模塊名</param>
    ''' <remarks></remarks>
    Private Sub SetListView(ByVal ModeNo As String)
        Try
            Dim Sql As String = ""
            Sql += "SELECT a.[ID],b.ModeName as [ModelName],[ReportDisName],[ReportFile],[SQLScript],[SQLExpItemCount]" + vbNewLine
            Sql += "FROM [ReportCfgMaster] a" + vbNewLine
            Sql += "left join Sys_ModeDefine b on a.ModelName=b.ModeNo" + vbNewLine
            Sql += "where 1=1" + vbNewLine
            Sql += "and ModelName='" + ModeNo + "'" + vbNewLine
            Dim dt As DataTable = Exec(Sql, E_ExecType.DataTable)
            Me.ListView1.Items.Clear()
            Dim imageindex As Int32 = -1
            If Me.ImageList1.Images.Count > 0 Then
                imageindex = 0
            End If
            For Each row As DataRow In dt.Rows
                Dim ReportDisName As String = row("ReportDisName").ToString()
                Dim item As ListViewItem = Me.ListView1.Items.Add(ReportDisName)
                item.ImageIndex = imageindex
                item.Tag = row("ID").ToString()
            Next
        Catch ex As Exception
            MessageBox.Show(Me.Name + "——SetListView:" + ex.Message, Msg.CompanyName, MessageBoxButtons.OKCancel, MessageBoxIcon.Information)
        End Try
    End Sub

    ''' <summary>
    ''' 顯示報表打印界面
    ''' </summary>
    ''' <param name="ReportID">報表的ID</param>
    ''' <remarks></remarks>
    Private Sub DisPlayForm(ByVal ReportID As String)
        Try
            Dim frm As New Frm_ReportSearch(ReportID)
            frm.StartPosition = FormStartPosition.CenterParent
            frm.ShowDialog()
        Catch ex As Exception
            MessageBox.Show(Me.Name + "—DisplayForm：" + ex.Message, Msg.CompanyName, MessageBoxButtons.OKCancel, MessageBoxIcon.Information)
        End Try
    End Sub
    ''' <summary>
    ''' 判斷是否以及InterFace的指定方法是否已經實現
    ''' </summary>
    ''' <param name="FrmName">用戶控件名稱</param>
    ''' <returns></returns>
    ''' <remarks></remarks>
    Private Function isInterfaceMethodFinished(ByVal FrmName As Object, Optional ByVal functionName As String = "ActionAdd") As Boolean
        Dim iftrue As Boolean = False
        If FrmName Is Nothing Then
            Return False
        End If
        Dim m As System.Reflection.MethodInfo = FrmName.GetType().GetMethod(functionName)
        If m Is Nothing Then
            Return False
        End If
        Dim body As System.Reflection.MethodBody = m.GetMethodBody
        '本地變量是否大于1（注：函數返回值也算作一個本地變量，因此對於Function來說，方法體沒有任何代碼，也有一個本地變量）或者含有TryCatch代碼段
        If body.LocalVariables.Count > 1 Or body.ExceptionHandlingClauses.Count > 0 Then
            iftrue = True
        Else
            iftrue = False
        End If
        Return iftrue
    End Function

#End Region

    Private Sub SplitContainer1_SizeChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SplitContainer1.SizeChanged
        'Me.SplitContainer1.SplitterDistance = 47
    End Sub
    Private Sub UpdateSoftToolStripMenuItem_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles UpdateSoftToolStripMenuItem.Click
        Dim filename As String = Path.Combine(Application.StartupPath, "update.vbs")
        If File.Exists(filename) Then
            System.Diagnostics.Process.Start(filename, Application.StartupPath)
            Application.Exit(New System.ComponentModel.CancelEventArgs(False))
        End If
    End Sub

End Class